﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DCTAccess.Business;
using DCTLib.Common;

namespace DCTAccess.Business.History
{
    public class WebHistoryAdminController
    {
        private static bool UpdateValue(WebHistoryAdmin historyAdmin, string action)
        {
            SQLHelper sqlHelper = new SQLHelper();
            string sProc = "WebHistoryAdmin";
            sqlHelper.AddParameter("@Action", action);
            sqlHelper.AddParameter("@HistoryID", historyAdmin.HistoryID);
            sqlHelper.AddParameter("@AdminID", historyAdmin.AdminID);
            sqlHelper.AddParameter("@HistoryTypeID", historyAdmin.HistoryTypeID);
            sqlHelper.AddParameter("@Description", historyAdmin.Description);
            return sqlHelper.ExecuteSQL(sProc);
        }

        public static bool Add(WebHistoryAdmin historyAdmin)
        {
            return UpdateValue(historyAdmin, StoreProceduAction.AddNew.ToString());
        }

        public static DataTable GetJoinDataTable(WebHistoryAdminFilter filter)
        {
            DataTable table = filter.GetJoinDataTable();
            if (ValidationHelper.HasRow(table))
                return table;
            return null;
        }
    }
}
